<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('列表')"/>
    <script th:src="@{/static/admin/js/pdf.js}"></script>
    <script th:src="@{/static/admin/js/pdf.worker.js}"></script>
</head>
<style>
    .evidence {
        width: 100%;
    }

    .evidence_left {
        float: left;
        width: 30%;
    }

    .evidence_right {
        float: right;
        width: 70%;
    }

    .clear {
        clear: both
    }

    .title {
        padding: 10px;
        display: block;
        border-left: #36b368 solid 4px;
        color: #333;
        font-weight: bold;
        font-size: 14px;
        background: #f2f2f2;
    }

    #iconicResult {
        /*margin-left: 30px;*/
        /*margin-top: 5px;*/
    }

    #iconicResult div {
        background: #eee;
        padding: 10px;
        border-bottom: #c9c9c9 solid 1px;
    }

    #iconicResult p {
        display: inline-block;
        line-height: 20px;
        margin-bottom: 10px;
        margin-right: 7px;
        font-size: 13px;
        padding: 0 5px;
        border-bottom: #f0f1f2 solid 1px;
    }

    #qualityBonus {
        /*margin-left: 30px;*/
        /*margin-top: 5px;*/
    }

    #qualityBonus div {
        background: #eee;
        padding: 10px;
        border-bottom: #c9c9c9 solid 1px;
    }

    #qualityBonus p {
        display: inline-block;
        line-height: 20px;
        margin-bottom: 10px;
        margin-right: 7px;
        font-size: 13px;
        padding: 0 5px;
        border-bottom: #f0f1f2 solid 1px;
    }
    #fileZip div {
        background: #eee;
        padding: 10px;
        border-bottom: #c9c9c9 solid 1px;
    }

    #fileZip p {
        display: inline-block;
        line-height: 20px;
        margin-bottom: 10px;
        margin-right: 7px;
        font-size: 13px;
        padding: 0 5px;
        border-bottom: #f0f1f2 solid 1px;
    }
</style>
<body class="pear-container">
<div class="evidence">
    <div style="margin-right: 20px;">
        <div class="evidence_left">
            <div style="margin-bottom: 20px;">
                <label class="title">文件--pdf</label>
                <div id="iconicResult"></div>
            </div>
            <div style="margin-bottom: 20px;">
                <label class="title">文件--jpg</label>
                <div id="qualityBonus"></div>
            </div>
            <div>
                <label class="title">文件--zip</label>
                <div id="fileZip"></div>
            </div>
        </div>
    </div>


    <div class="evidence_right">
        <iframe id="pdf" width="100%"></iframe>
    </div>
    <div class="clear"></div>
</div>


</body>
<th:block th:include="include :: footer"/>
<script th:inline="javascript" type="text/javascript">

    var upload = layui.upload;

    var MODULE_PATH = rootPath + "/InfoFileController/";

    var iconicResultHtml = "";
    var qualityBonusHtml = "";
    var fileZipHtml = "";
    var infoFiles = [[${infoFiles}]];
    var recordId = [[${recordId}]];
    var fkSubject = [[${fkSubject}]];
    var taskid = [[${taskid}]];
    for (var i = 0; i < infoFiles.length; i++) {
        console.log(infoFiles[i].fileName)
        if (infoFiles[i].suffix === '.pdf') {
            // if (taskScoreProofList[i].privates === '1') {
            iconicResultHtml += '<div><p>' + infoFiles[i].fileName + '</p>' +
                '<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" onclick="viewFile(\'' + infoFiles[i].fileUrl + '\')">查看</button></div>';
            // }
        }
        if (infoFiles[i].suffix === '.jpg') {
            // if (taskScoreProofList[i].privates === '1') {
            qualityBonusHtml += '<div><p>' + infoFiles[i].fileName + '</p>' +
                '<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" onclick="viewFilejpg(\'' + infoFiles[i].fileUrl + '\')">查看</button></div>';
            // }
        }
        if (infoFiles[i].suffix === '.zip') {
            var downloadName = infoFiles[i].fileName;
            console.log('====================='+downloadName)
            // if (taskScoreProofList[i].privates === '1') {
            fileZipHtml += '<div><p>' + infoFiles[i].fileName + '</p>' +
                '<button type="button" class="layui-btn layui-btn-sm layui-btn-warm" onclick="downloadSingle(\'' + infoFiles[i].id +'\',\''+ infoFiles[i].fileName+'\')">下载</button></div>';
            // }
        }
        $('#iconicResult').html(iconicResultHtml);
        $('#qualityBonus').html(qualityBonusHtml);
        $('#fileZip').html(fileZipHtml);
    }

    function viewFile(e) {
        $("#pdf").attr("height", $(document).height());
        $("#pdf").attr("src", e);
    }

    function viewFilejpg(e) {
        var index = layer.open({
            type: 2 ,
            title: '支撑文件查看',
            shade: 0.1,
            // area: ['1500px', '800px'],
            // area: ['1500px', '800px'],
            content: MODULE_PATH + 'upload/pic?e='+e
        });
        layer.full(index)
    }

    //单个文件下载
    function downloadSingle(id,fileName) {
        console.log("xxxxxxxxxxxxxxxxxxxxxxx"+fileName)
        var url = MODULE_PATH + "downloadsingle/" + id;
        var timestamp = Date.parse(new Date());
        downloadFile(url, fileName);
    }

    function getCorroborationList() {
        $.ajax({
            url: MODULE_PATH + 'getFilebyRecordId',
            dataType: 'json',
            type: 'post',
            data: {
                fkRecord: recordId,
                fkSubject: fkSubject,
                taskid: taskid
            },
            success: function (result) {
                var listFiles = result.listFiles;
                var pdfLists = '';
                var jpgLists = '';
                var zipLists = '';
                console.log(listFiles)
                for (var i = 0; i < listFiles.length; i++) {
                    if (listFiles[i].suffix === '.pdf') {
                        // if (taskScoreProofList[i].privates === '1') {
                        pdfLists += '<div><p>' + listFiles[i].fileName + '</p>' +
                            '<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" onclick="viewFile(\'' + listFiles[i].fileUrl + '\')">查看</button></div>';
                        // }
                    }
                    if (listFiles[i].suffix === '.jpg') {
                        // if (taskScoreProofList[i].privates === '1') {
                        jpgLists += '<div><p>' + listFiles[i].fileName + '</p>' +
                            '<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" onclick="viewFile(\'' + listFiles[i].fileUrl + '\')">查看</button></div>';
                        // }
                    }
                    if (listFiles[i].suffix === '.zip') {
                        // if (taskScoreProofList[i].privates === '1') {
                        zipLists += '<div><p>' + listFiles[i].fileName + '</p>' +
                            '<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" onclick="viewFile(\'' + listFiles[i].fileUrl + '\')">查看</button></div>';
                        // }
                    }
                    // supportingLists += '<div id="fileName" style="float:left; line-height: 38px; margin-right: 10px;">' + corroborationList[i].fileName +
                    //     '<span style="width:40px; text-align:center; font-size: 12px; display:inline-block; height:30px; line-height: 30px; margin-left:10px; background: #f56c6c; color: #fff;  cursor: pointer;" onclick="delFile(\'' + corroborationList[i].id + '\',\'' + [i].localPath +
                    //     '\')">删除</span><div class="clear"></div></div>';
                }
                $('#iconicResult').html(pdfLists)
                $('#qualityBonus').html(jpgLists);
                $('#fileZip').html(zipLists);
            }
        })
    }
</script>
</html>